<?php
function select_all($table){
	$sql = "select * from $table; ";
	$record = mysql_query($sql);
	return $record;
}

function update($value,$table)
{
		$c=count($value);
		$i=0;
		$sql="UPDATE $table SET ";
		
		
		foreach($value as $x=>$y)
		{
			if($i<$c-2)
			$sql .= "$x = '$y' ,";
			elseif($i<$c-1)
			$sql .= "$x = '$y' ";
			else $sql .= "WHERE $x = '$y' ;";
			
			$i++;
		}
		echo $sql;
		$result=mysql_query($sql);
		
		$result_end = $result ? TRUE : FALSE;
				
		return $result_end;
}

function delete($id,$table)
{
		$sql="DELETE FROM $table WHERE ";
		foreach($id as $x=>$y)
		{
			$sql .= "$x = '$y' ;";	
		}
		echo $sql;
		$result=mysql_query($sql);
		
		$result_end = $result ? TRUE : FALSE;
		return $result_end;
}

function create_field($field)
{
	$s="<tr>";
	foreach($field as $value)
	{
		$s.="<th>";
		$s.=$value;
		$s.="</th>";	
	}
	$s.="</tr>";	
	
	return $s;
}
?>